# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: JJDaNiMoTh <jjdanimoth.aur@gmail.com>
# Contributor: Tino Reichardt <milky-archlinux@mcmilk.de>

pkgname=sarg
pkgver=2.4.0
pkgrel=3
pkgdesc="Squid Analysis Report Generator"
arch=('loong64' 'x86_64')
url="http://sarg.sourceforge.net"
license=('GPL')
depends=('gd' 'libldap')
makedepends=('cmake')
backup=('etc/sarg/css.tpl'
	'etc/sarg/exclude_codes'
	'etc/sarg/sarg.conf'
	'etc/sarg/user_limit_block')
source=(https://downloads.sourceforge.net/sourceforge/sarg/$pkgname-$pkgver.tar.gz
	build-fix.patch)
sha256sums=('b4ca0f41f6467673b4c65c6798b44a8886f08180c055eb11c37a96dfc28cb5c3'
            'a243156aed182fe8f0db1032d585b4966f56ab432085f581b91b8faf9ac0e973')

prepare() {
  cd "$srcdir"/$pkgname-$pkgver
  patch -p1 <"$srcdir"/build-fix.patch
}

build() {
  cd "$srcdir"/$pkgname-$pkgver
  cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DSYSCONFDIR=/etc/sarg \
    -DMANDIR=/usr/share/man/man1 \
    .
  make C_FLAGS="-Wno-error"
}

package() {
  cd "$srcdir"/$pkgname-$pkgver
  mkdir -p "$pkgdir"/usr/share/sarg "$pkgdir"/etc
  make DESTDIR="$pkgdir" install
}
